var express = require('express');
var router = express.Router();
const {getAdmins,delAdmins,addAdmins,changeAdmins, changeAdminsCode} =require('../service/adminsService')

/* GET users listing. */
// router.get('/', function(req, res, next) {
//   res.send('respond with a resource');
// });


//管理员渲染
router.get('/getAdmins',async function(req, res) {
    const data=await getAdmins(req.query);
  res.send(data);
});

//删除管理员
//delAdmins
router.post('/delAdmins',async function(req, res) {
    const data=await delAdmins(req.body);
    res.send(data);
});

//新增管理员
router.post('/addAdmins', async function (req, res) {
    const { account,password,code } = req.body;
    const data = await addAdmins({account,password,code });
    console.log(req.body, 2222);
    res.send(data)

})

//修改管理员
router.post('/changeAdmins', async function (req, res) {
    const data = await changeAdmins(req.body);
    res.send(data)

})
//修改管理员权限
router.post('/changeAdminsCode', async function (req, res) {
    const data = await changeAdminsCode(req.body);
    res.send(data)

})




module.exports = router;
